package org.vfinal.sonidosl3tcraft;

import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.view.View;

public class ReproducirSonido {

	public int getIdAudio(View view, int position, int autor, Context contexto) {
		Cursor fila = null;
		// Context contexto = getActivity().getApplicationContext();
		BaseDeDatos b77 = new BaseDeDatos(contexto);
		SQLiteDatabase db = b77.getReadableDatabase();

		// Si hemos abierto correctamente la base de datos
		if (db != null) {
			fila = db.rawQuery("SELECT * FROM Frases WHERE autor=" + autor
					+ ";", null);
			fila.moveToPosition(position);
			db.close();
			b77.close();
		}
		int resID = contexto.getResources().getIdentifier(fila.getString(3),
				"raw", contexto.getPackageName());
		fila.close();
		return resID;

	}
}
